﻿using LiveCharts;
using LiveCharts.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WpfApp001.Core;

namespace WpfApp001.Model
{
    public class CourseInfo : NotifyBase
    {
        public class ItemInfo : NotifyBase
        {
            public ItemInfo(string _itemTitle,string _arrows,string _percentage,string _color,int _clicks) {

                this.Arrows = _arrows;
                this.Percentage = _percentage;
                this.Color = _color;
                this.Clicks = _clicks;
                this.ItemTitle = _itemTitle;
            }


            private string itemTitle;

            public string ItemTitle
            {
                get { return itemTitle; }
                set { itemTitle = value; this.DoNotify(); }
            }

            private string arrows;

            public string Arrows
            {
                get { return arrows; }
                set { arrows = value; this.DoNotify(); }
            }

            private string percentage;

            public string Percentage
            {
                get { return percentage; }
                set { percentage = value; this.DoNotify(); }
            }

            private string color;

            public string Color
            {
                get { return color; }
                set { color = value; this.DoNotify(); }
            }

            private int clicks;
            public int Clicks
            {
                get { return clicks; }
                set { clicks = value; this.DoNotify(); }
            }
        }

        public CourseInfo(string _title, List<ItemInfo> items) {
        
            this.Title= _title;             
            this.PieSeriesCollection = new SeriesCollection();
            this.Children = new List<ItemInfo>();
            foreach (var item in items)
            {
                this.Children.Add(item);

                PieSeriesCollection.Add(new PieSeries
                {
                    Title = item.ItemTitle,
                    Values = new ChartValues<double> { item.Clicks },
                    DataLabels = true,
                });
            }
            

        }

        private List<ItemInfo> children;

        public List<ItemInfo> Children
        {
            get { return children; }
            set { children = value; this.DoNotify(); }
        }


        private string title;

        public string Title
        {
            get { return title; }
            set { title = value; this.DoNotify(); }
        } 

        private SeriesCollection pieSeriesCollection;
        public SeriesCollection PieSeriesCollection {

            get { return pieSeriesCollection; }
            set { pieSeriesCollection = value; this.DoNotify(); }
        }

        


    }
}
